<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-cn">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="配置," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="全称: Tom的（语义）明显、（配置）最小化的语言。(Tom’s Obvious, Minimal Language. By Tom Preston-Werner.)">
<meta property="og:type" content="article">
<meta property="og:title" content="TOML v0.4.0 脚本配置语言">
<meta property="og:url" content="http://tudouabc.oschina.io/2017/02/21/toml-v0.4.0/index.html">
<meta property="og:site_name" content="倔强的土豆">
<meta property="og:description" content="全称: Tom的（语义）明显、（配置）最小化的语言。(Tom’s Obvious, Minimal Language. By Tom Preston-Werner.)">
<meta property="og:updated_time" content="2017-02-21T04:52:38.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="TOML v0.4.0 脚本配置语言">
<meta name="twitter:description" content="全称: Tom的（语义）明显、（配置）最小化的语言。(Tom’s Obvious, Minimal Language. By Tom Preston-Werner.)">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://tudouabc.oschina.io/2017/02/21/toml-v0.4.0/"/>





  <title> TOML v0.4.0 脚本配置语言 | 倔强的土豆 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-cn">

  














  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">倔强的土豆</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">粘贴过来，鼓励并充实自己~</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocapitalize="off" autocomplete="off" autocorrect="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://tudouabc.oschina.io/2017/02/21/toml-v0.4.0/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="倔强的土豆">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/user.jpg">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="倔强的土豆">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="倔强的土豆" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                TOML v0.4.0 脚本配置语言
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-21T17:14:11+08:00">
                2017-02-21
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/脚本/" itemprop="url" rel="index">
                    <span itemprop="name">脚本</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>全称: Tom的（语义）明显、（配置）最小化的语言。<br>(Tom’s Obvious, Minimal Language. By Tom Preston-Werner.)<br><a id="more"></a></p>
<p>注: 此规范仍然会发生很多变化。在未标记为1.0之前，你应该假设它是不稳定的，请酌情采用。</p>
<h2 id="目标"><a href="#目标" class="headerlink" title="目标"></a>目标</h2><p>TOML的目标是成为一个有明显语义而容易去阅读的最小化配置文件格式。<br>TOML被设计成可以无歧义地被映射为哈希表，从而很容易的被解析成各种语言中的数据结构。</p>
<h2 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h2><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div></pre></td><td class="code"><pre><div class="line"># 这是TOML文档示例.</div><div class="line"></div><div class="line">title = "TOML Example"</div><div class="line"></div><div class="line">[owner]</div><div class="line">name = "Lance Uppercut"</div><div class="line">dob = 1979-05-27T07:32:00-08:00 # 时间日期当然是一等公民了。</div><div class="line"></div><div class="line">[database]</div><div class="line">server = "192.168.1.1"</div><div class="line">ports = [ 8001, 8001, 8002 ]</div><div class="line">connection_max = 5000</div><div class="line">enabled = true</div><div class="line"></div><div class="line">[servers]</div><div class="line"></div><div class="line">  # 你可以按你的意愿缩进。TOML并不关心你是用Tab还是空格。</div><div class="line">  [servers.alpha]</div><div class="line">  ip = "10.0.0.1"</div><div class="line">  dc = "eqdc10"</div><div class="line"></div><div class="line">  [servers.beta]</div><div class="line">  ip = "10.0.0.2"</div><div class="line">  dc = "eqdc10"</div><div class="line"></div><div class="line">[clients]</div><div class="line">data = [ ["gamma", "delta"], [1, 2] ]</div><div class="line"></div><div class="line"># 数组里可以换行</div><div class="line">hosts = [</div><div class="line">  "alpha",</div><div class="line">  "omega"</div><div class="line">]</div></pre></td></tr></table></figure>
<h2 id="规格"><a href="#规格" class="headerlink" title="规格"></a>规格</h2><ul>
<li>TOML是大小写敏感的。</li>
<li>TOML文件必须只包含UTF-8编码的Unicode字符。</li>
<li>空格是指制表符(0x09) 或空格 (0x20)。</li>
<li>换行符是指LF(0x0A)或CRLF (0x0D0A).</li>
</ul>
<h2 id="注释"><a href="#注释" class="headerlink" title="注释"></a>注释</h2><p>用符号#来表示注释：</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># I am a comment. Hear me roar. Roar.</span></div><div class="line"><span class="attr">key</span> = <span class="string">"value"</span> # Yeah, you can do this.</div></pre></td></tr></table></figure>
<h2 id="字符串"><a href="#字符串" class="headerlink" title="字符串"></a>字符串</h2><p>有四种方法来表示字符串：基本字符串、多行基本字符串、字面量和多行字面量。所有的字符串必须只包含有效的UTF-8字符。</p>
<p><strong>基本字符串</strong> 是由引号括起来的任意字符串，除了那些必须要转义的，比如：双引号、反斜杠和控制字符(U+0000到U+001F)。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">"I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."</div></pre></td></tr></table></figure>
<p>常用的转义序列：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">\b         - backspace       (U+0008)</div><div class="line">\t         - tab             (U+0009)</div><div class="line">\n         - linefeed        (U+000A)</div><div class="line">\f         - form feed       (U+000C)</div><div class="line">\r         - carriage return (U+000D)</div><div class="line">\&quot;         - quote           (U+0022)</div><div class="line">\\         - backslash       (U+005C)</div><div class="line">\uXXXX     - unicode         (U+XXXX)</div><div class="line">\UXXXXXXXX - unicode         (U+XXXXXXXX)</div></pre></td></tr></table></figure>
<p>任意Unicode字符都可能被转义为<code>\uXXXX</code> 或 <code>\UXXXXXXXX</code>的形式。这些转义代码必须是有效的Unicode<a href="http://unicode.org/glossary/#unicode_scalar_value" target="_blank" rel="external">标量值</a>。</p>
<p>所有未出现在上面名单中的转义序列必须保留，如果使用，TOML应该会产生错误。</p>
<p>有时你需要表达一段文本（比如，翻译文件），或者是将很长的字符串分成多行。TOML很容易处理这种情况。<br><strong>多行基本字符串</strong> 是被三引号括起来的字符串，并且允许换行。紧跟起始界定符后面的换行符会被剪掉，而其他的所有空格和换行字符仍然被保留。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="attr">key1</span> = <span class="string">"""</span></div><div class="line">Roses are red</div><div class="line">Violets are blue"""</div></pre></td></tr></table></figure>
<p>TOML解析器应该能正常处理不同平台下的换行符。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 对于Unix系统，上面的多行字符串应该是这样的:</span></div><div class="line"><span class="attr">key2</span> = <span class="string">"Roses are red\nViolets are blue"</span></div><div class="line"></div><div class="line"><span class="comment"># 对于Windows系统，最可能等价于这样的:</span></div><div class="line"><span class="attr">key3</span> = <span class="string">"Roses are red\r\nViolets are blue"</span></div></pre></td></tr></table></figure>
<p>在行尾使用<code>\</code>，可以避免在写长字符串的时候引入多余的空格。<br><code>\</code>将会删除当前位置到下个非空字符或结束界定符之间的所有空格（包括换行符）。<br>如果在起始界定符之后的第一个字符是反斜杠和一个换行符，那么从此位置到下个非空白字符或结束界定符之间的所有空格和换行符都会被剪掉。<br>所有的转义序列对基本字符串都有效，也对多行基本字符串有效。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 以下每个字符串都是相同的</span></div><div class="line"><span class="attr">key1</span> = <span class="string">"The quick brown fox jumps over the lazy dog."</span></div><div class="line"></div><div class="line"><span class="attr">key2</span> = <span class="string">"""</span></div><div class="line">The quick brown \</div><div class="line"></div><div class="line"></div><div class="line">  fox jumps over \</div><div class="line">    the lazy dog."""</div><div class="line"></div><div class="line"><span class="attr">key3</span> = <span class="string">"""\</span></div><div class="line">       The quick brown \</div><div class="line">       fox jumps over \</div><div class="line">       the lazy dog.\</div><div class="line">       """</div></pre></td></tr></table></figure>
<p>任何Unicode字符都可能被用到，除了那些可能需要转义的字符：反斜杠和控制字符(U+0000 到 U+001F)。<br>引号不需要转义，除非它们的存在可能会造成提前关闭界定符。</p>
<p>如果你需要频繁的指定Windows的路径或正则表达式，那么不得不添加转义符就会变的繁琐和容易出错。<br>TOML支持完全不允许转义的字面量字符串来帮助你解决此类问题。<br><strong>字面量字符串</strong> 是被单引号包含的字符串，跟基本字符串一样，它们一定是以单行出现:</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 所见即所得.</span></div><div class="line"><span class="attr">winpath</span>  = <span class="string">'C:\Users\nodejs\templates'</span></div><div class="line"><span class="attr">winpath2</span> = <span class="string">'\\ServerX\admin$\system32\'</span></div><div class="line">quoted   = 'Tom <span class="string">"Dubs"</span> Preston-Werner<span class="string">'</span></div><div class="line">regex    = '&lt;\i\c*\s*&gt;<span class="string">'</span></div></pre></td></tr></table></figure>
<p>因为没有转义，所以在一个被单引号封闭的字面量字符串里面没有办法写单引号。<br>幸运的是，TOML支持多行版本的字面量字符串来解决这个问题。<br><strong>多行字面量字符串</strong> 是被三个单引号括起来的字符串，并且允许换行。<br>跟字面量字符串一样，这也没有任何转义。<br>紧跟起始界定符的换行符会被剪掉。界定符之间的所有其他内容都会被按照原样解释而无需修改。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="attr">regex2</span> = <span class="string">'''I [dw]on't need \d&#123;2&#125; apples'''</span></div><div class="line"><span class="attr">lines</span>  = <span class="string">'''</span></div><div class="line">The first newline is</div><div class="line">trimmed in raw strings.</div><div class="line">   All other whitespace</div><div class="line">   is preserved.</div><div class="line">'''</div></pre></td></tr></table></figure>
<p>对于二进制数据，建议你使用Base64或其他适合的编码，比如ASCII或UTF-8编码。具体的处理取决于特定的应用。</p>
<h2 id="整数"><a href="#整数" class="headerlink" title="整数"></a>整数</h2><p>整数就是没有小数点的数字。正数前面也可以用加号，负数需要用负号前缀表示。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">+99</div><div class="line">42</div><div class="line">0</div><div class="line">-17</div></pre></td></tr></table></figure>
<p>对于大整数，你可以用下划线提高可读性。每个下划线两边至少包含一个数字。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">1_000</div><div class="line">5_349_221</div><div class="line">1_2_3_4_5     # 有效，但不建议这样写</div></pre></td></tr></table></figure>
<p>前导零是不允许的。也不允许十六进制（Hex）、八进制（octal）和二进制形式。<br>诸如“无穷”和“非数字”这样的不能用一串数字表示的值都不被允许。</p>
<p>预期的范围是64位 (signed long)(−9,223,372,036,854,775,808 到<br>9,223,372,036,854,775,807).</p>
<h2 id="浮点数"><a href="#浮点数" class="headerlink" title="浮点数"></a>浮点数</h2><p>一个浮点数由整数部分（可能是带有加号或减号前缀的）和小数部分和（或）指数部分组成的数。<br>如果只有小数部分和指数部分，那么小数部分必须放在指数部分前面。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"># 小数</div><div class="line">+1.0</div><div class="line">3.1415</div><div class="line">-0.01</div><div class="line"></div><div class="line"># 指数</div><div class="line">5e+22</div><div class="line">1e6</div><div class="line">-2E-2</div><div class="line"></div><div class="line"># 小数和指数同时存在</div><div class="line">6.626e-34</div></pre></td></tr></table></figure>
<p>小数部分是指在小数点后面的一个或多个数字。</p>
<p>指数部分是指E（大写或小写）后面的整数部分（可能用加号或减号为前缀）</p>
<p>和整数类似，你可以用下划线来提高可读性。每个下划线两边至少包含一个数字。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">9_224_617.445_991_228_313</div><div class="line">1e1_000</div></pre></td></tr></table></figure>
<p>预期精度为64位 (double)。</p>
<h2 id="布尔值"><a href="#布尔值" class="headerlink" title="布尔值"></a>布尔值</h2><p>布尔值是小写的true和false。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">true</div><div class="line">false</div></pre></td></tr></table></figure>
<h2 id="时间日期"><a href="#时间日期" class="headerlink" title="时间日期"></a>时间日期</h2><p>时间日期是<a href="http://tools.ietf.org/html/rfc3339" target="_blank" rel="external">RFC 3339</a>中的时间格式。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">1979-05-27T07:32:00Z</div><div class="line">1979-05-27T00:32:00-07:00</div><div class="line">1979-05-27T00:32:00.999999-07:00</div></pre></td></tr></table></figure>
<h2 id="数组"><a href="#数组" class="headerlink" title="数组"></a>数组</h2><p>数组是由方括号包括的基本单元。空格会被忽略。<br>数组中的元素由逗号分隔。数据类型不能混用（所有的字符串均为同一类型）。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[ 1, 2, 3 ]</div><div class="line">[ "red", "yellow", "green" ]</div><div class="line">[ [ 1, 2 ], [3, 4, 5] ]</div><div class="line">[ "all", 'strings', """are the same""", '''type'''] # 这样可以</div><div class="line">[ [ 1, 2 ], ["a", "b", "c"] ] # 这样可以</div><div class="line">[ 1, 2.0 ] # 注: 这样不行</div></pre></td></tr></table></figure>
<p>数组也可以多行。所以，除了忽略空格之外，数组也忽略了括号之间的换行符。<br>在结束括号之前存在逗号是可以的。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">key = [</div><div class="line">  1, 2, 3</div><div class="line">]</div><div class="line"></div><div class="line">key = [</div><div class="line">  1,</div><div class="line">  2, # 这样可以</div><div class="line">]</div></pre></td></tr></table></figure>
<h2 id="表"><a href="#表" class="headerlink" title="表"></a>表</h2><p>表（也被称为哈希表或字典）是键值对集合。表格名由方括号包裹，自成一行。<br>注意和数组相区分，数组里只有值。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="section">[table]</span></div></pre></td></tr></table></figure>
<p>在表名之下，直到下一个表或文件尾（EOF）之间都是该表的键值对。<br>键是等号符左边的值，值是等号符右边的值。<br>键名和值周围的空格都将被忽略。<br>键、等号和值，一定要在同一行（有些值可以多行表示）</p>
<p>键可以是裸的或由引号包括的。<strong>裸键</strong> 可能仅包含字母、数字、下划线和破折号。<br><strong>引号键</strong> 遵循基本字符串的规则，允许你使用更广泛的键名。<br>除非有绝对的必要，否则最好是用裸键。</p>
<p>表中的键值对是无序的。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">[table]</div><div class="line">key = "value"</div><div class="line">bare_key = "value"</div><div class="line">bare-key = "value"</div><div class="line"></div><div class="line">"127.0.0.1" = "value"</div><div class="line">"character encoding" = "value"</div><div class="line">"ʎǝʞ" = "value"</div></pre></td></tr></table></figure>
<p>点（.）严禁在裸键中使用，因为它被用来表示嵌套表！<br>命名规则为被点分隔的部分应该属于同一个键。（见上文）。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="section">[dog."tater.man"]</span></div><div class="line"><span class="attr">type</span> = <span class="string">"pug"</span></div></pre></td></tr></table></figure>
<p>等价于如下JSON格式：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&#123; <span class="attr">"dog"</span>: &#123; <span class="attr">"tater.man"</span>: &#123; <span class="attr">"type"</span>: <span class="string">"pug"</span> &#125; &#125; &#125;</div></pre></td></tr></table></figure>
<p>被点分隔部分周围的空格都会被忽略，但是最好不要使用任何多余的空格。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="section">[a.b.c]</span>          <span class="comment"># this is best practice</span></div><div class="line"><span class="section">[ d.e.f ]</span>        <span class="comment"># same as [d.e.f]</span></div><div class="line"><span class="section">[ g .  h  . i ]</span>  <span class="comment"># same as [g.h.i]</span></div><div class="line"><span class="section">[ j . "ʞ" . l ]</span>  <span class="comment"># same as [j."ʞ".l]</span></div></pre></td></tr></table></figure>
<p>如果你不想，你可以完全不去指定父表（super-tables）。TOML知道该如何处理。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># [x] 你</span></div><div class="line"><span class="comment"># [x.y] 不</span></div><div class="line"><span class="comment"># [x.y.z] 需要这些</span></div><div class="line"><span class="section">[x.y.z.w]</span> <span class="comment"># 去处理这种情况</span></div></pre></td></tr></table></figure>
<p>空表是允许的，其中没有键值对。</p>
<p>只要父表没有被直接定义，而且没有定义特定的键，你可以继续写入。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="section">[a.b]</span></div><div class="line"><span class="attr">c</span> = <span class="number">1</span></div><div class="line"><span class="section"></span></div><div class="line">[a]</div><div class="line"><span class="attr">d</span> = <span class="number">2</span></div></pre></td></tr></table></figure>
<p>你不能多次定义键或表。这样做是无效的。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 不要这么做</span></div><div class="line"><span class="section"></span></div><div class="line">[a]</div><div class="line"><span class="attr">b</span> = <span class="number">1</span></div><div class="line"><span class="section"></span></div><div class="line">[a]</div><div class="line"><span class="attr">c</span> = <span class="number">2</span></div></pre></td></tr></table></figure>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 也不要这样做</span></div><div class="line"><span class="section"></span></div><div class="line">[a]</div><div class="line"><span class="attr">b</span> = <span class="number">1</span></div><div class="line"><span class="section"></span></div><div class="line">[a.b]</div><div class="line"><span class="attr">c</span> = <span class="number">2</span></div></pre></td></tr></table></figure>
<p>所有的表名和键一定不能为空。<br>All table names and keys must be non-empty.</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"># 无效TOML</div><div class="line">[]</div><div class="line">[a.]</div><div class="line">[a..b]</div><div class="line">[.b]</div><div class="line">[.]</div><div class="line"> = "no key name" # 不允许</div></pre></td></tr></table></figure>
<h2 id="内联表"><a href="#内联表" class="headerlink" title="内联表"></a>内联表</h2><p>内联表提供一种更紧凑的语法来表示表。它们可以把数据分组，避免这些数据很快变得冗长。<br>内联表是由大括号<code>{</code> 和 <code>}</code>括起来的。在大括号内可以存在零个或多个逗号分隔的键值对。<br>内联表里的键值对跟标准表里的键值对形式是一样的。允许所有的值类型，包括内联表。</p>
<p>内联表一般以单行出现。不允许换行符出现在大括号之间，除非是包含在值中的有效字符。<br>即便如此，也强烈建议不要在把内联表分成多行。如果你有这种需求，那么你应该去用标准表。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="attr">name</span> = &#123; first = <span class="string">"Tom"</span>, last = <span class="string">"Preston-Werner"</span> &#125;</div><div class="line"><span class="attr">point</span> = &#123; x = <span class="number">1</span>, y = <span class="number">2</span> &#125;</div></pre></td></tr></table></figure>
<p>上面的内联表完全等同于下面的标准表定义：</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="section">[name]</span></div><div class="line"><span class="attr">first</span> = <span class="string">"Tom"</span></div><div class="line"><span class="attr">last</span> = <span class="string">"Preston-Werner"</span></div><div class="line"><span class="section"></span></div><div class="line">[point]</div><div class="line"><span class="attr">x</span> = <span class="number">1</span></div><div class="line"><span class="attr">y</span> = <span class="number">2</span></div></pre></td></tr></table></figure>
<h2 id="表数组"><a href="#表数组" class="headerlink" title="表数组"></a>表数组</h2><p>最后要介绍的类型是表数组。表数组可以通过包括在双括号内表格名来表达。<br>使用相同双括号名的每个表都是数组中的元素。表的顺序跟书写顺序一致。<br>没有键值对的双括号表会被当作空表。</p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="section">[[products]]</span></div><div class="line"><span class="attr">name</span> = <span class="string">"Hammer"</span></div><div class="line"><span class="attr">sku</span> = <span class="number">738594937</span></div><div class="line"><span class="section"></span></div><div class="line">[[products]]</div><div class="line"><span class="section"></span></div><div class="line">[[products]]</div><div class="line"><span class="attr">name</span> = <span class="string">"Nail"</span></div><div class="line"><span class="attr">sku</span> = <span class="number">284758393</span></div><div class="line"><span class="attr">color</span> = <span class="string">"gray"</span></div></pre></td></tr></table></figure>
<p>等价于如下JSON格式：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">  <span class="attr">"products"</span>: [</div><div class="line">    &#123; <span class="attr">"name"</span>: <span class="string">"Hammer"</span>, <span class="attr">"sku"</span>: <span class="number">738594937</span> &#125;,</div><div class="line">    &#123; &#125;,</div><div class="line">    &#123; <span class="attr">"name"</span>: <span class="string">"Nail"</span>, <span class="attr">"sku"</span>: <span class="number">284758393</span>, <span class="attr">"color"</span>: <span class="string">"gray"</span> &#125;</div><div class="line">  ]</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>你也能创建内嵌的表数组。只需要对子表使用相同的双括号语法就可以。每个双括号子表将属于其上面最近定义的那个表。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">[[fruit]]</div><div class="line">  name = "apple"</div><div class="line"></div><div class="line">  [fruit.physical]</div><div class="line">    color = "red"</div><div class="line">    shape = "round"</div><div class="line"></div><div class="line">  [[fruit.variety]]</div><div class="line">    name = "red delicious"</div><div class="line"></div><div class="line">  [[fruit.variety]]</div><div class="line">    name = "granny smith"</div><div class="line"></div><div class="line">[[fruit]]</div><div class="line">  name = "banana"</div><div class="line"></div><div class="line">  [[fruit.variety]]</div><div class="line">    name = "plantain"</div></pre></td></tr></table></figure>
<p>上面的TOML对应于下面的JSON格式：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">  <span class="attr">"fruit"</span>: [</div><div class="line">    &#123;</div><div class="line">      <span class="attr">"name"</span>: <span class="string">"apple"</span>,</div><div class="line">      <span class="attr">"physical"</span>: &#123;</div><div class="line">        <span class="attr">"color"</span>: <span class="string">"red"</span>,</div><div class="line">        <span class="attr">"shape"</span>: <span class="string">"round"</span></div><div class="line">      &#125;,</div><div class="line">      <span class="attr">"variety"</span>: [</div><div class="line">        &#123; <span class="attr">"name"</span>: <span class="string">"red delicious"</span> &#125;,</div><div class="line">        &#123; <span class="attr">"name"</span>: <span class="string">"granny smith"</span> &#125;</div><div class="line">      ]</div><div class="line">    &#125;,</div><div class="line">    &#123;</div><div class="line">      <span class="attr">"name"</span>: <span class="string">"banana"</span>,</div><div class="line">      <span class="attr">"variety"</span>: [</div><div class="line">        &#123; <span class="attr">"name"</span>: <span class="string">"plantain"</span> &#125;</div><div class="line">      ]</div><div class="line">    &#125;</div><div class="line">  ]</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>试图用已经定义的数组的名称来定义的正常表，在解析的时候一定会抛出错误。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"># INVALID TOML DOC</div><div class="line">[[fruit]]</div><div class="line">  name = "apple"</div><div class="line"></div><div class="line">  [[fruit.variety]]</div><div class="line">    name = "red delicious"</div><div class="line"></div><div class="line">  # This table conflicts with the previous table</div><div class="line">  [fruit.variety]</div><div class="line">    name = "granny smith"</div></pre></td></tr></table></figure>
<p>你也可以在适合的地方使用内联表。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">points = [ &#123; x = 1, y = 2, z = 3 &#125;,</div><div class="line">           &#123; x = 7, y = 8, z = 9 &#125;,</div><div class="line">           &#123; x = 2, y = 4, z = 8 &#125; ]</div></pre></td></tr></table></figure>
<h2 id="这份规范是认真的吗？"><a href="#这份规范是认真的吗？" class="headerlink" title="这份规范是认真的吗？"></a>这份规范是认真的吗？</h2><p>当然。</p>
<h2 id="但是为什么我要用它呢？"><a href="#但是为什么我要用它呢？" class="headerlink" title="但是为什么我要用它呢？"></a>但是为什么我要用它呢？</h2><p>因为我们需要一个像样的人类可读的格式，同时能无歧义地映射到哈希表。<br>而且YAML的规范有80页那么长，真是令人发指！<br>不，不考虑JSON 。你知道为什么。</p>
<h2 id="天哪，你说的好有道理"><a href="#天哪，你说的好有道理" class="headerlink" title="天哪，你说的好有道理"></a>天哪，你说的好有道理</h2><p>哈哈！想帮忙么？发pull request过来。或者编写一个解析器。你可以勇敢一点。</p>
<h2 id="使用TOML的项目"><a href="#使用TOML的项目" class="headerlink" title="使用TOML的项目"></a>使用TOML的项目</h2><ul>
<li><a href="http://doc.crates.io/" target="_blank" rel="external">Cargo</a> - Rust语言的包管理器。</li>
<li><a href="http://influxdb.com/" target="_blank" rel="external">InfluxDB</a> - 分布式时间序列数据库。</li>
<li><a href="https://hekad.readthedocs.org" target="_blank" rel="external">Heka</a> - Mozilla的流处理系统。</li>
<li><a href="http://gohugo.io/" target="_blank" rel="external">Hugo</a> - Go的静态站点生成器。</li>
</ul>
<h2 id="实现"><a href="#实现" class="headerlink" title="实现"></a>实现</h2><p>如果你有一个实现，请发一个合并请求，把你的实现加入到这个列表中。<br>请在你实现的解析器README中标记你的解析器支持的提交SHA1或版本号。</p>
<ul>
<li>C#/.NET - <a href="https://github.com/LBreedlove/Toml.net" target="_blank" rel="external">https://github.com/LBreedlove/Toml.net</a></li>
<li>C#/.NET - <a href="https://github.com/rossipedia/toml-net" target="_blank" rel="external">https://github.com/rossipedia/toml-net</a></li>
<li>C#/.NET - <a href="https://github.com/RichardVasquez/TomlDotNet" target="_blank" rel="external">https://github.com/RichardVasquez/TomlDotNet</a></li>
<li>C#/.NET - <a href="https://github.com/azyobuzin/HyperTomlProcessor" target="_blank" rel="external">https://github.com/azyobuzin/HyperTomlProcessor</a></li>
<li>C (@ajwans) - <a href="https://github.com/ajwans/libtoml" target="_blank" rel="external">https://github.com/ajwans/libtoml</a></li>
<li>C (@mzgoddard) - <a href="https://github.com/mzgoddard/tomlc" target="_blank" rel="external">https://github.com/mzgoddard/tomlc</a></li>
<li>C++ (@evilncrazy) - <a href="https://github.com/evilncrazy/ctoml" target="_blank" rel="external">https://github.com/evilncrazy/ctoml</a></li>
<li>C++ (@skystrife) - <a href="https://github.com/skystrife/cpptoml" target="_blank" rel="external">https://github.com/skystrife/cpptoml</a></li>
<li>C++ (@mayah) - <a href="https://github.com/mayah/tinytoml" target="_blank" rel="external">https://github.com/mayah/tinytoml</a></li>
<li>Clojure (@lantiga) - <a href="https://github.com/lantiga/clj-toml" target="_blank" rel="external">https://github.com/lantiga/clj-toml</a></li>
<li>Clojure (@manicolosi) - <a href="https://github.com/manicolosi/clojoml" target="_blank" rel="external">https://github.com/manicolosi/clojoml</a></li>
<li>CoffeeScript (@biilmann) - <a href="https://github.com/biilmann/coffee-toml" target="_blank" rel="external">https://github.com/biilmann/coffee-toml</a></li>
<li>Common Lisp (@pnathan) - <a href="https://github.com/pnathan/pp-toml" target="_blank" rel="external">https://github.com/pnathan/pp-toml</a></li>
<li>D - <a href="https://github.com/iccodegr/toml.d" target="_blank" rel="external">https://github.com/iccodegr/toml.d</a></li>
<li>Dart (@just95) - <a href="https://github.com/just95/toml.dart" target="_blank" rel="external">https://github.com/just95/toml.dart</a></li>
<li>Erlang - <a href="https://github.com/kalta/etoml.git" target="_blank" rel="external">https://github.com/kalta/etoml.git</a></li>
<li>Erlang - <a href="https://github.com/kaos/tomle" target="_blank" rel="external">https://github.com/kaos/tomle</a></li>
<li>Emacs Lisp (@gongoZ) - <a href="https://github.com/gongo/emacs-toml" target="_blank" rel="external">https://github.com/gongo/emacs-toml</a></li>
<li>Go (@thompelletier) - <a href="https://github.com/pelletier/go-toml" target="_blank" rel="external">https://github.com/pelletier/go-toml</a></li>
<li>Go (@laurent22) - <a href="https://github.com/laurent22/toml-go" target="_blank" rel="external">https://github.com/laurent22/toml-go</a></li>
<li>Go w/ Reflection (@BurntSushi) - <a href="https://github.com/BurntSushi/toml" target="_blank" rel="external">https://github.com/BurntSushi/toml</a></li>
<li>Go (@achun) - <a href="https://github.com/achun/tom-toml" target="_blank" rel="external">https://github.com/achun/tom-toml</a></li>
<li>Go (@naoina) - <a href="https://github.com/naoina/toml" target="_blank" rel="external">https://github.com/naoina/toml</a></li>
<li>Haskell (@seliopou) - <a href="https://github.com/seliopou/toml" target="_blank" rel="external">https://github.com/seliopou/toml</a></li>
<li>Haxe (@raincole) - <a href="https://github.com/raincole/haxetoml" target="_blank" rel="external">https://github.com/raincole/haxetoml</a></li>
<li>Java (@agrison) - <a href="https://github.com/agrison/jtoml" target="_blank" rel="external">https://github.com/agrison/jtoml</a></li>
<li>Java (@johnlcox) - <a href="https://github.com/johnlcox/toml4j" target="_blank" rel="external">https://github.com/johnlcox/toml4j</a></li>
<li>Java (@mwanji) - <a href="https://github.com/mwanji/toml4j" target="_blank" rel="external">https://github.com/mwanji/toml4j</a></li>
<li>Java - <a href="https://github.com/asafh/jtoml" target="_blank" rel="external">https://github.com/asafh/jtoml</a></li>
<li>Java w/ ANTLR (@MatthiasSchuetz) - <a href="https://github.com/mschuetz/toml" target="_blank" rel="external">https://github.com/mschuetz/toml</a></li>
<li>Julia (@pygy) - <a href="https://github.com/pygy/TOML.jl" target="_blank" rel="external">https://github.com/pygy/TOML.jl</a></li>
<li>Literate CoffeeScript (@JonathanAbrams) - <a href="https://github.com/JonAbrams/tomljs" target="_blank" rel="external">https://github.com/JonAbrams/tomljs</a></li>
<li>Nim (@ziotom78) - <a href="https://github.com/ziotom78/parsetoml" target="_blank" rel="external">https://github.com/ziotom78/parsetoml</a></li>
<li>node.js/browser - <a href="https://github.com/ricardobeat/toml.js" target="_blank" rel="external">https://github.com/ricardobeat/toml.js</a> (npm install tomljs)</li>
<li>node.js - <a href="https://github.com/BinaryMuse/toml-node" target="_blank" rel="external">https://github.com/BinaryMuse/toml-node</a></li>
<li>node.js/browser (@redhotvengeance) - <a href="https://github.com/redhotvengeance/topl" target="_blank" rel="external">https://github.com/redhotvengeance/topl</a> (topl npm package)</li>
<li>node.js/browser (@alexanderbeletsky) - <a href="https://github.com/alexanderbeletsky/toml-js" target="_blank" rel="external">https://github.com/alexanderbeletsky/toml-js</a> (npm browser amd)</li>
<li>Objective C (@mneorr) - <a href="https://github.com/mneorr/toml-objc.git" target="_blank" rel="external">https://github.com/mneorr/toml-objc.git</a></li>
<li>Objective-C (@SteveStreza) - <a href="https://github.com/amazingsyco/TOML" target="_blank" rel="external">https://github.com/amazingsyco/TOML</a></li>
<li>OCaml (@mackwic) <a href="https://github.com/mackwic/to.ml" target="_blank" rel="external">https://github.com/mackwic/to.ml</a></li>
<li>Perl (@alexkalderimis) - <a href="https://github.com/alexkalderimis/config-toml.pl" target="_blank" rel="external">https://github.com/alexkalderimis/config-toml.pl</a></li>
<li>Perl - <a href="https://github.com/dlc/toml" target="_blank" rel="external">https://github.com/dlc/toml</a></li>
<li>PHP (@leonelquinteros) - <a href="https://github.com/leonelquinteros/php-toml.git" target="_blank" rel="external">https://github.com/leonelquinteros/php-toml.git</a></li>
<li>PHP (@jimbomoss) - <a href="https://github.com/jamesmoss/toml" target="_blank" rel="external">https://github.com/jamesmoss/toml</a></li>
<li>PHP (@coop182) - <a href="https://github.com/coop182/toml-php" target="_blank" rel="external">https://github.com/coop182/toml-php</a></li>
<li>PHP (@checkdomain) - <a href="https://github.com/checkdomain/toml" target="_blank" rel="external">https://github.com/checkdomain/toml</a></li>
<li>PHP (@zidizei) - <a href="https://github.com/zidizei/toml-php" target="_blank" rel="external">https://github.com/zidizei/toml-php</a></li>
<li>PHP (@yosymfony) - <a href="https://github.com/yosymfony/toml" target="_blank" rel="external">https://github.com/yosymfony/toml</a></li>
<li>Python (@f03lipe) - <a href="https://github.com/f03lipe/toml-python" target="_blank" rel="external">https://github.com/f03lipe/toml-python</a></li>
<li>Python (@uiri) - <a href="https://github.com/uiri/toml" target="_blank" rel="external">https://github.com/uiri/toml</a></li>
<li>Python - <a href="https://github.com/bryant/pytoml" target="_blank" rel="external">https://github.com/bryant/pytoml</a></li>
<li>Python (@elssar) - <a href="https://github.com/elssar/tomlgun" target="_blank" rel="external">https://github.com/elssar/tomlgun</a></li>
<li>Python (@marksteve) - <a href="https://github.com/marksteve/toml-ply" target="_blank" rel="external">https://github.com/marksteve/toml-ply</a></li>
<li>Python (@hit9) - <a href="https://github.com/hit9/toml.py" target="_blank" rel="external">https://github.com/hit9/toml.py</a></li>
<li>Racket (@greghendershott) - <a href="https://github.com/greghendershott/toml" target="_blank" rel="external">https://github.com/greghendershott/toml</a></li>
<li>Ruby (@jm) - <a href="https://github.com/jm/toml" target="_blank" rel="external">https://github.com/jm/toml</a> (toml gem)</li>
<li>Ruby (@eMancu) - <a href="https://github.com/eMancu/toml-rb" target="_blank" rel="external">https://github.com/eMancu/toml-rb</a> (toml-rb gem)</li>
<li>Ruby (@charliesome) - <a href="https://github.com/charliesome/toml2" target="_blank" rel="external">https://github.com/charliesome/toml2</a> (toml2 gem)</li>
<li>Ruby (@sandeepravi) - <a href="https://github.com/sandeepravi/tomlp" target="_blank" rel="external">https://github.com/sandeepravi/tomlp</a> (tomlp gem)</li>
<li>Rust (@mneumann) - <a href="https://github.com/mneumann/rust-toml" target="_blank" rel="external">https://github.com/mneumann/rust-toml</a></li>
<li>Rust (@alexcrichton) - <a href="https://github.com/alexcrichton/toml-rs" target="_blank" rel="external">https://github.com/alexcrichton/toml-rs</a></li>
<li>Scala - <a href="https://github.com/axelarge/tomelette" target="_blank" rel="external">https://github.com/axelarge/tomelette</a></li>
</ul>
<h2 id="校验"><a href="#校验" class="headerlink" title="校验"></a>校验</h2><ul>
<li>Go (@BurntSushi) - <a href="https://github.com/BurntSushi/toml/tree/master/cmd/tomlv" target="_blank" rel="external">https://github.com/BurntSushi/toml/tree/master/cmd/tomlv</a></li>
</ul>
<h2 id="TOML解码器和编码器测试套件（语言无关）"><a href="#TOML解码器和编码器测试套件（语言无关）" class="headerlink" title="TOML解码器和编码器测试套件（语言无关）"></a>TOML解码器和编码器测试套件（语言无关）</h2><ul>
<li>toml-test (@BurntSushi) - <a href="https://github.com/BurntSushi/toml-test" target="_blank" rel="external">https://github.com/BurntSushi/toml-test</a></li>
</ul>
<h2 id="支持的编辑器"><a href="#支持的编辑器" class="headerlink" title="支持的编辑器"></a>支持的编辑器</h2><ul>
<li>Atom - <a href="https://github.com/atom/language-toml" target="_blank" rel="external">https://github.com/atom/language-toml</a></li>
<li>Emacs (@dryman) - <a href="https://github.com/dryman/toml-mode.el" target="_blank" rel="external">https://github.com/dryman/toml-mode.el</a></li>
<li>Notepad++ (@fireforge) - <a href="https://github.com/fireforge/toml-notepadplusplus" target="_blank" rel="external">https://github.com/fireforge/toml-notepadplusplus</a></li>
<li>Sublime Text 2 &amp; 3 (@Gakai) - <a href="https://github.com/Gakai/sublime_toml_highlighting" target="_blank" rel="external">https://github.com/Gakai/sublime_toml_highlighting</a></li>
<li>Synwrite - <a href="http://uvviewsoft.com/synwrite/download.html" target="_blank" rel="external">http://uvviewsoft.com/synwrite/download.html</a> ; call Options/ Addons manager/ Install</li>
<li>TextMate (@infininight) - <a href="https://github.com/textmate/toml.tmbundle" target="_blank" rel="external">https://github.com/textmate/toml.tmbundle</a></li>
<li>Vim (@cespare) - <a href="https://github.com/cespare/vim-toml" target="_blank" rel="external">https://github.com/cespare/vim-toml</a></li>
</ul>
<h2 id="编码器"><a href="#编码器" class="headerlink" title="编码器"></a>编码器</h2><ul>
<li>Dart (@just95) - <a href="https://github.com/just95/toml.dart" target="_blank" rel="external">https://github.com/just95/toml.dart</a></li>
<li>Go w/ Reflection (@BurntSushi) - <a href="https://github.com/BurntSushi/toml" target="_blank" rel="external">https://github.com/BurntSushi/toml</a></li>
<li>PHP (@ayushchd) - <a href="https://github.com/ayushchd/php-toml-encoder" target="_blank" rel="external">https://github.com/ayushchd/php-toml-encoder</a></li>
</ul>
<h2 id="转换器"><a href="#转换器" class="headerlink" title="转换器"></a>转换器</h2><ul>
<li>remarshal (@dbohdan) - <a href="https://github.com/dbohdan/remarshal" target="_blank" rel="external">https://github.com/dbohdan/remarshal</a></li>
<li>yaml2toml (@jtyr) - <a href="https://github.com/jtyr/yaml2toml-converter" target="_blank" rel="external">https://github.com/jtyr/yaml2toml-converter</a></li>
<li>yaml2toml.dart (@just95) - <a href="https://github.com/just95/yaml2toml.dart" target="_blank" rel="external">https://github.com/just95/yaml2toml.dart</a></li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/配置/" rel="tag"># 配置</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/02/21/Animate.css/" rel="next" title="Animate动画">
                <i class="fa fa-chevron-left"></i> Animate动画
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/user.jpg"
               alt="倔强的土豆" />
          <p class="site-author-name" itemprop="name">倔强的土豆</p>
           
              <p class="site-description motion-element" itemprop="description">学习和整理web技术，方面自己查阅，也希望方便他人</p>
          
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#目标"><span class="nav-number">1.</span> <span class="nav-text">目标</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#示例"><span class="nav-number">2.</span> <span class="nav-text">示例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#规格"><span class="nav-number">3.</span> <span class="nav-text">规格</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#注释"><span class="nav-number">4.</span> <span class="nav-text">注释</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#字符串"><span class="nav-number">5.</span> <span class="nav-text">字符串</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#整数"><span class="nav-number">6.</span> <span class="nav-text">整数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#浮点数"><span class="nav-number">7.</span> <span class="nav-text">浮点数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#布尔值"><span class="nav-number">8.</span> <span class="nav-text">布尔值</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#时间日期"><span class="nav-number">9.</span> <span class="nav-text">时间日期</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数组"><span class="nav-number">10.</span> <span class="nav-text">数组</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#表"><span class="nav-number">11.</span> <span class="nav-text">表</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#内联表"><span class="nav-number">12.</span> <span class="nav-text">内联表</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#表数组"><span class="nav-number">13.</span> <span class="nav-text">表数组</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#这份规范是认真的吗？"><span class="nav-number">14.</span> <span class="nav-text">这份规范是认真的吗？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#但是为什么我要用它呢？"><span class="nav-number">15.</span> <span class="nav-text">但是为什么我要用它呢？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#天哪，你说的好有道理"><span class="nav-number">16.</span> <span class="nav-text">天哪，你说的好有道理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用TOML的项目"><span class="nav-number">17.</span> <span class="nav-text">使用TOML的项目</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#实现"><span class="nav-number">18.</span> <span class="nav-text">实现</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#校验"><span class="nav-number">19.</span> <span class="nav-text">校验</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TOML解码器和编码器测试套件（语言无关）"><span class="nav-number">20.</span> <span class="nav-text">TOML解码器和编码器测试套件（语言无关）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#支持的编辑器"><span class="nav-number">21.</span> <span class="nav-text">支持的编辑器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#编码器"><span class="nav-number">22.</span> <span class="nav-text">编码器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#转换器"><span class="nav-number">23.</span> <span class="nav-text">转换器</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">倔强的土豆</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  





  





  



  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

  


  

</body>
</html>
